import { createStore } from 'vuex'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    tableData:[], // 表格的数据
  },
  getters: {
  },
  mutations: {
    saveData(state,val){ // 存储表格数据的
      let obj = {...val,time:new Date().toLocaleDateString()}
      // console.log(obj);
      state.tableData.push(obj);
    },
    del(state,i){ // 删除
      state.tableData.splice(i,1);
    },
    update(state,val){ // 更新的函数
      // console.log(val);
      state.tableData[val.i] = val.msg;
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
      storage: window.localStorage,
    }),
  ],
})
